//
//  BCFlagsTool.m
//  BangcaiSale
//
//  Created by Liang Zhang on 16/7/16.
//  Copyright © 2016年 Bangcai. All rights reserved.
//

#import "BCFlagsTool.h"

@implementation BCFlagsTool

FlagBool read_flag(int index,int value)
{
    if(value&(1<<index))
    {
        return FlagBool_YES;
    }
    else {
        return FlagBool_NO;
    }
}

int write_flag(int index,int value, FlagBool arg) {
    
    unsigned short int i_flag = value;
    unsigned short int scan_arg = 0x01<<index;
    
    if (FlagBool_YES == arg) {
        //同为1，异为0
        return (i_flag|scan_arg);
    }
    else {
        //同为0，异为1
        return (i_flag^scan_arg);
    }
}

@end
